#include <iostream>
#include <vector>
#include <algorithm>
#include "function.h"
using namespace std;

vector<student> students; // 存储学生信息
vector<book> books;       // 存储图书信息

int main()
{
    
    while (1)
    {
        int i = 0;
        cout << "请输入您的身份:" << endl;
        cout << "1.管理员" << endl;
        cout << "2.学生" << endl;
        cout << "3.退出" << endl;
        cin >> i;
        if (i == 1) // 管理员
        {
            system("clear");
            administrators();
        }
        else if (i == 2) // 学生
        {
            system("clear");
            string username, password;
            cout << "请输入用户名: ";
            cin >> username;
            cout << "请输入密码: ";
            cin >> password;

            auto it = find_if(students.begin(), students.end(), [&username, &password](const student &s)
                              { return s.name == username && s.password == password; });
            if (it != students.end())
            {
                system("clear");
                studentMenu(username);
            }
            else
            {
                cout << "用户名或密码错误！" << endl;
            }
            // break;
        }
        else if (i == 3) // 退出
        {
            return 0;
        }
        else
        {
            cout << "输入错误请重新输入" << endl;
        }
    }
}